<?php

/**
 * 系统模块管理logic
 */

namespace Manage\Logic;

class ModuleLogic extends CommonLogic {
    
	/**
	 * 获取全部的可用的模块
	 */
	public function allLists($map = array('status'=>1),$field = array('id','name','title')){
		//查询条件
	    $lists = $this->where($map)->field($field)->select();
	    
	    if(isset($lists['config'])){
	    	$lists['config'] = serializeMysql($lists['config'],1);
	    }
	    $moudles = array();
	    foreach ($lists as $v){
	        $moudles[$v['name']] = $v;
	    }
	    return $moudles;
	    
	}
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::update()
	 */
	public function update($id = 0){
		/* 获取文章数据 */
		$data = $this->create();
		
		$data['uid'] = UID;
		
		if($data === false){
			return false;
		}
		
		/* 添加或更新数据 */
		if(empty($data['id'])){//新增数据
			$data['id'] = $id;
			$id = $this->add($data);
			if(!$id){
				$this->error = '新增详细内容失败！';
				return false;
			}
		} else { //更新数据
			$status = $this->save($data);
			if(false === $status){
				$this->error = '更新详细内容失败！';
				return false;
			}
		}
		
		return true;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::autoSave()
	 */
	public function autoSave($id = 0){
		 
	}
}